package com.zjx.controller;

import com.zjx.Service.WelcomeService;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Controller;

/**
 * @author zjx
 * @create 2020-03-29 16:18
 */
@Controller
public class WelcomeController implements ApplicationContextAware, BeanNameAware {
	private String myName;
	private ApplicationContext myContainer;
	@Autowired
	private WelcomeService welcomeService;
	public void handRequest(){
		welcomeService.sayHello("来自controller的问候");
		System.out.println("我是谁"+myName);
		String[] beanDefinitionNames = myContainer.getBeanDefinitionNames();
		for (String s:beanDefinitionNames){
			System.out.println(s);
		}
	}

	@Override
	public void setBeanName(String name) {
		this.myName=name;
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
			this.myContainer=applicationContext;
	}
}
